//
//  ServeViewController.m
//  服务条款
//
//  Created by lanou on 15/12/23.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "ServeViewController.h"
#import "LeftSortViewController.h"

@interface ServeViewController ()



@end

@implementation ServeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBackGroundColor;
    [self setServe];
    
    
    //    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    //    backButton.frame = CGRectMake(15, kHeight - 640, 30, 30);
    //    [backButton addTarget:self action:@selector(dismiss) forControlEvents:(UIControlEventTouchUpInside)];
    //    [backButton setImage:[UIImage imageNamed:@"arrowdown"] forState:(UIControlStateNormal)];
    //    backButton.backgroundColor = [UIColor blackColor];
    //    [backButton setTintColor:[UIColor whiteColor]];
    
    //    [self.view addSubview:backButton];
    self.navigationController.navigationBar.barTintColor = kNaviBarColor;
    
    
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"关闭" style:(UIBarButtonItemStyleDone) target:self action:@selector(backToF)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    //    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:(UIBarButtonItemStyleDone) target:self action:nil];
    
    
    
    
    
    
    
    // Do any additional setup after loading the view.
}

- (void)setServe{
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    scrollView.contentSize = CGSizeMake(kWidth, kHeight * 2.1);
    scrollView.scrollEnabled = YES;
    scrollView.showsVerticalScrollIndicator = YES; //隐藏竖直滚动条
    scrollView.showsHorizontalScrollIndicator = YES;
    [self.view addSubview:scrollView];
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(kWidth / 2 - kWidth / 4 / 2, kHeight / 26.68, kWidth/ 4, kWidth / 4)];
    imageView.image = [UIImage imageNamed:@"main"];
    
    imageView.layer.masksToBounds = YES;
    //边角颜色
    //    imageView.layer.borderColor = [kBackGroundColor CGColor];
    //    imageView.layer.borderWidth = 2.0;
    imageView.layer.cornerRadius = 15;
    
    [scrollView addSubview:imageView];
    
    
    
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidth /37.5, kHeight /5.1 + kHeight / 26.68, 100, 20)];
    titleLabel.text = @"版本信息:";
    titleLabel.font = [UIFont boldSystemFontOfSize:15];
    titleLabel.textColor = [UIColor darkGrayColor];
    [scrollView addSubview:titleLabel];
    
    UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidth /12.5, kHeight/4.44 + kHeight / 22.23, kWidth/1.13, 30)];
    textLabel.text = @"车友管家适用于iOS8.0及以上的系统的设备。";
    textLabel.font = [UIFont systemFontOfSize:14];
    textLabel.textColor = [UIColor darkGrayColor];
    textLabel.numberOfLines = 0;
    [textLabel sizeToFit];
    [scrollView addSubview:textLabel];
    
    
    UILabel *titleLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(kWidth /37.5, kHeight /3.7+ kHeight / 22.23, 100, 20)];
    titleLabel1.text = @"免责声明:";
    titleLabel1.textColor = [UIColor darkGrayColor];
    titleLabel1.font = [UIFont boldSystemFontOfSize:15];
    [scrollView addSubview:titleLabel1];
    
    
    UILabel *textLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(kWidth/12.5, kHeight /3.335+ kHeight / 22.23, kWidth/1.17, kHeight * 2)];
    textLabel1.font = [UIFont systemFontOfSize:14];
    textLabel1.textColor = [UIColor darkGrayColor];
    textLabel1.text = @"    1.一切移动客户端用户在下载并使用本软件时均被视为已经仔细阅读本条款并完全同意。凡以任何方式登陆本软件，或直接、间接使用本APP资料者，均被视为自愿接受本声明和用户服务协议的约束。\n\n    2.本软件使用完全免费，手机由于上网而产生的GPRS流量费用由运营商收取。\n\n    3.本软件转载的内容并不代表本软件之意见及观点，也不意味着软件作者赞同其观点或证实其内容的真实性。\n\n    4.本软件所转载的文字、图片、音视频等内容均由互联网收集，对其真实性、准确性和合法性本软件不提供任何保证，也不承担任何法律责任。如有真实性、准确性和合法性存在问题的内容，请联系开发者及时删除相关内容。\n\n     5.本软件所转载的文字、图片、音视频等内容均由互联网自动收集，如侵犯了第三方的知识产权或其他权利，请联系开发者删除相关内容，本软件对此不承担任何法律责任。\n\n   6.本软件不保证为向用户提供便利而设置的外部链接的准确性和完整性，同时，对于该外部链接指向的不由本软件实际控制的任何网页上的内容，本软件不承担任何责任。\n\n     7.用户明确并同意其使用本软件网络服务所存在的风险将完全由其本人承担；因其使用本软件网络服务而产生的一切后果也由其本人承担，本软件对此不承担任何责任。\n\n   8.除本软件注明之服务条款外，其它因不当使用本APP而导致的任何意外、疏忽、合约毁坏、诽谤、版权或其他知识产权侵犯及其所造成的任何损失，本软件概不负责，亦不承担任何法律责任。\n\n   9.对于因不可抗力或因黑客攻击、通讯线路中断等本软件不能控制的原因造成的网络服务中断或其他缺陷，导致用户不能正常使用本软件，本软件不承担任何责任，但将尽力减少因此给用户造成的损失或影响。\n\n   10.本声明未涉及的问题请参见国家有关法律法规，当本声明与国家有关法律法规冲突时，以国家法律法规为准。\n\n   11.本软件版权及其修改权、更新权和最终解释权均属本软件开发者所有。";
    CGFloat height = [self heightForString:textLabel1.text];
    CGRect rect = textLabel1.frame;
    rect.size.height = height;
    textLabel1.frame = rect;
    CGFloat maxY = CGRectGetMaxY(textLabel1.frame);
    scrollView.contentSize = CGSizeMake(kWidth, maxY + kHeight / 4);
    textLabel1.numberOfLines = 0;
    [scrollView addSubview:textLabel1];
    
    
    
    
    
    
    
    
    
}

- (CGFloat)heightForString:(NSString *)string{
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName];
    CGRect bounds =  [string boundingRectWithSize:CGSizeMake(kWidth/1.17, kHeight * 2) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
    return bounds.size.height;
    
}

- (void)backToF{
    [self.navigationController popToRootViewControllerAnimated:YES];
    
    //    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
